<template>
<!-- 微信群机器人 -->
  <!-- 搜索工作栏 -->
  <div v-show="setView==='list'">
    <Search :schema="allSchemas.searchSchema" @search="setSearchParams" :show-reset="false"  @reset="setSearchParams">
    </Search>
  <div style="margin-top: 10px;">
      
</div>
    <!-- 列表 -->
      <Table
        :columns="allSchemas.tableColumns"
        :data="tableObject.tableList"
        :loading="loading"
        :pagination="{
          total: tableObject.total
        }"
        v-model:pageSize="tableObject.pageSize"
        v-model:currentPage="tableObject.currentPage"
         :stripe="true"
        header-cell-class-name="custom-header"
      >
    <template #createTime="{ row }">
      <el-button
          link
          type="primary"
         @click="openDetail(row.id)"
        >
        {{ row.createTime }}
        </el-button>
      </template>
      <template #pslStatus="{ row }">
        <span >{{ row.pslStatus =='1'?'成功':'失败' }}</span>
      </template>
    </Table>
  </div>
  <ContentWrap v-show="setView==='view'">
  <!-- 详情弹窗 -->
  <sendFilesDetail ref="detailRef" @setClose=setClose  />
</ContentWrap>
</template>
<script lang="ts" setup>
import { allSchemas } from './sendFiles.data';
import * as weComNewsApi from '@/api/news/weComNews';
import sendFilesDetail from './sendFilesDetail.vue';

defineOptions({ name: 'SendFiles' })
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
// tableObject：表格的属性对象，可获得分页大小、条数等属性
// tableMethods：表格的操作对象，可进行获得分页、删除记录等操作
// 详细可见：https://doc.iocoder.cn/vue3/crud-schema/
const { tableObject, tableMethods } = useTable(
  {
    getListApi: weComNewsApi.getsendMessagePage, // 分页接口
    defaultParams:{pslType:'2',msgType:'2'} //传递默认数据
  }
)
// 获得表格的各种操作
const { getList, setSearchParams } = tableMethods
const loading = ref(false)
const setView = ref('list');
const setViewFun=(type:string)=>{
  setView.value=type;
}
const setClose=()=>{
  setView.value='list';
}
const tableData=[
  {
    name:'机器人1',
    webHookUrl:'https://qyapi.weixin.qq.com/cgibin/webhook/send?key=c73daa86-3321-4731-a233-1abfd16f2839',
    isGroup:true,
    status:true
  }
]
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number|string) => {
  formRef.value.open(type, id)
}

/** 详情操作 */
const detailRef = ref()
const openDetail = (id: number|string) => {
  detailRef.value.open(id)
  setViewFun('view')

}



/** 初始化 **/
onMounted(() => {
  getList()
})
</script>
